Skip to content

feat(audio): add sound effects toggle for keypresses and guess submissions - #1309

Merged
kike-alt merged 1 commit into
kike-alt:mainfrom
lovesmilesmall-hue:feat/issue-1257-sound-effects-toggle
Aug 26, 2026
Merged

feat(audio): add sound effects toggle for keypresses and guess submissions#1309
kike-alt merged 1 commit into
kike-alt:mainfrom
lovesmilesmall-hue:feat/issue-1257-sound-effects-toggle

Conversation

@lovesmilesmall-hue

@lovesmilesmall-hue lovesmilesmall-hue commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1257
Closes #1231
Closes #1258
Closes #1259
Adds Web Audio API sound effects for keypresses, guess submissions, and win conditions, with a toggle switch in the Settings panel (default off). The sound service initializes the AudioContext lazily on first user interaction to comply with browser autoplay policies.

Why

Audio feedback enhances tactile game feel for players who prefer sound. The implementation uses the Web Audio API's OscillatorNode synthesis rather than pre-loaded audio files, keeping the bundle size zero and enabling fine-grained control over tone parameters. The toggle persists to localStorage via the existing SettingsProvider.

What was built

frontend/src/services/soundService.ts:

Export What it contains
playSound(type) Synthesizes tones for keypress (440 Hz square), submit (330+440 Hz sine), win (C5-E5-G5 arpeggio)
initAudioContext() Pre-initializes AudioContext on user gesture for safe resume

frontend/src/providers/settings-provider.tsx — Added soundEffects: boolean to GameSettings type and setSoundEffects callback. Defaults to false.

frontend/src/components/SettingsPanel.tsx — Added "Sound effects" toggle switch below the existing Color-blind mode toggle, matching the same switch component pattern.

Integration changes outside services/

  • frontend/src/providers/settings-provider.tsx — Extended GameSettings type with soundEffects field and exposed setSoundEffects setter. Backward-compatible: existing localStorage data without soundEffects defaults to false.
  • frontend/src/components/SettingsPanel.tsx — Added toggle UI; consumes new soundEffects / setSoundEffects from useSettings().

No existing files deleted or broken.

Acceptance criteria coverage

  • Add audio synthesis sound effects for keypress, row submission, and win condition (soundService.tsplaySound("keypress"), playSound("submit"), playSound("win"))
  • Provide Sound Effects toggle switch in Settings panel (default off) (SettingsPanel.tsx — toggle with id="sound-toggle", default false)
  • Ensure web audio context initializes safely on user interaction (soundService.ts — lazy AudioContext creation, ctx.resume() on suspended state)

Test plan

  • npm test — not run per instruction
  • npm run build — not run per instruction

Env vars / Notes

No new environment variables. Sound effects are client-side only via Web Audio API. The soundService.ts module is safe to import in SSR contexts (returns early if typeof window === "undefined").

…sions

- Create soundService.ts with Web Audio API synthesis for keypress,
  submit, and win sounds
- Add soundEffects setting to SettingsProvider with localStorage persistence
- Add sound effects toggle switch in SettingsPanel (default off)
- Web Audio context initializes safely on first user interaction

Closes kike-alt#1257
@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@lovesmilesmall-hue Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@kike-alt
kike-alt merged commit b537f86 into kike-alt:main Aug 26, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants